package com.trade.module.base.repository;

import com.trade.module.base.entity.Department;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Class Description:
 *
 * @Version v1.0 2017/5/1 1:38
 * @JDK version 1.8.0_51
 * @Author zfb
 */
@Repository
public interface DepartmentRepository extends JpaSpecificationExecutor<Department>,
        PagingAndSortingRepository<Department, String> {

    /**
     * 根据部门id获取部门对象
     *
     * @param deptId   部门id
     * @param dataFlag 部门删除状态
     * @param deptFlag 部门启用状态
     * @return Department
     */
    Department findByIdAndDeptFlagAndDataFlag(String deptId,
                                              String dataFlag,
                                              String deptFlag);

    /**
     * 根据部门级别获取部门集合
     *
     * @param deptLevel 部门级别
     * @return 部门
     */
    List<Department> findByDeptLevel(String deptLevel);

    /**
     * 根据父节点id查找组织集合
     * @param parentId 父节点id
     * @return Department集合
     */
    List<Department> findByParentDeptId(String parentId);
}
